#pragma once
#pragma once
#include "CWindow/CMDIFrameBase.h"
#include <vector>
#include "Common.h"
#include "Win32Utils/CStrUtils.h"
#include "CWindowViewer.h"
#include "CWindowPalette.h"
#include "CWindowTile.h"

class CWindowFrame :
    public CMDIFrameBase
{
public:
    CWindowFrame();
    ~CWindowFrame();


    wnd_msg LRESULT OnCreate(WPARAM wParam, LPARAM lParam);
    wnd_msg LRESULT OnClose(WPARAM wParam, LPARAM lParam);
    wnd_msg LRESULT OnDestroy(WPARAM wParam, LPARAM lParam);
    wnd_msg LRESULT OnPaint(WPARAM wParam, LPARAM lParam);

    wnd_msg LRESULT OnLoadFile(WPARAM wParam, LPARAM lParam);
    wnd_msg LRESULT OnSize(WPARAM wParam, LPARAM lParam);
    wnd_msg LRESULT OnGetMinMaxInfo(WPARAM wParam, LPARAM lParam);

    wnd_command LRESULT OnViewToolBar(WORD wNotify, WORD wID, HWND hWnd);
    wnd_command LRESULT OnViewStatusBar(WORD wNotify, WORD wID, HWND hWnd);

    wnd_command LRESULT OnFileOpen(WORD wNotify, WORD wID, HWND hWnd);
    wnd_command LRESULT OnExportBitmap(WORD wNotify, WORD wID, HWND hWnd);
    wnd_command LRESULT OnFileSaveAs(WORD wNotify, WORD wID, HWND hWnd);
    wnd_command LRESULT OnFileClose(WORD wNotify, WORD wID, HWND hWnd);
    wnd_command LRESULT OnFileExit(WORD wNotify, WORD wID, HWND hWnd);

    wnd_command LRESULT OnZoomIn(WORD wNotify, WORD wID, HWND hWnd);
    wnd_command LRESULT OnZoomOut(WORD wNotify, WORD wID, HWND hWnd);
    wnd_command LRESULT OnWidth16Tiles(WORD wNotify, WORD wID, HWND hWnd);
    wnd_command LRESULT OnWidth32Tiles(WORD wNotify, WORD wID, HWND hWnd);
    wnd_command LRESULT OnHeight16Tiles(WORD wNotify, WORD wID, HWND hWnd);
    wnd_command LRESULT OnHeight32Tiles(WORD wNotify, WORD wID, HWND hWnd);

    wnd_command LRESULT OnZoomSize1(WORD wNotify, WORD wID, HWND hWnd);
    wnd_command LRESULT OnZoomSize2(WORD wNotify, WORD wID, HWND hWnd);
    wnd_command LRESULT OnZoomSize4(WORD wNotify, WORD wID, HWND hWnd);
    wnd_command LRESULT OnZoomSize8(WORD wNotify, WORD wID, HWND hWnd);
    wnd_command LRESULT OnZoomSize16(WORD wNotify, WORD wID, HWND hWnd);
    wnd_command LRESULT OnZoomSize32(WORD wNotify, WORD wID, HWND hWnd);
    wnd_command LRESULT OnZoomSize64(WORD wNotify, WORD wID, HWND hWnd);

    wnd_command LRESULT OnPaintMode(WORD wNotify, WORD wID, HWND hWnd);
    wnd_command LRESULT OnShowGrid(WORD wNotify, WORD wID, HWND hWnd);

    LRESULT OnTile(WORD wNotify, WORD wID, HWND hWnd);
    LRESULT OnCascade(WORD wNotify, WORD wID, HWND hWnd);
    LRESULT OnIconArrange(WORD wNotify, WORD wID, HWND hWnd);
    LRESULT OnCloseAll(WORD wNotify, WORD wID, HWND hWnd);

    virtual LRESULT OnAfterCreate(const LPCREATESTRUCT lpCs);
    virtual LRESULT OnAfterChildActivate(HWND hWnd);
    virtual LRESULT OnGetMinMaxInfo(LPMINMAXINFO lpInfo);
    virtual LRESULT UpdateStatusBar();
    virtual LRESULT UpdateToolBar();

    virtual LRESULT OnMDIMessage(LPMDI_MESSAGE_DATA lpMsg);
    virtual LRESULT OnChildMessage(LPMDI_MESSAGE_DATA lpMsg);
    virtual LRESULT OnAfterChildDestroy(HWND hWnd);
    virtual LRESULT OnClientMessage(UINT uMsg, WPARAM wParam, LPARAM lParam);

    wnd_msg LRESULT OnTileClear(WPARAM wParam, LPARAM lParam);

private:

    CWindowViewer* GetActivateViewer();

private:

    DECLARE_WND_BASE_MESSAGE_MAP()

private:

    HDC         m_hMemDC = NULL;
    HBITMAP     m_hMemBitmap = NULL;

    CWindowPalette m_wndPalette;
    CWindowTile    m_wndTile;
    HWND           m_hActivateViewer;

    bool           m_fBusy = false;
};
